package com.zengqingfa.springboot.validation.demo.controller;

import com.zengqingfa.springboot.validation.demo.entity.CreateUserDto;
import com.zengqingfa.springboot.validation.demo.entity.UserDto;
import com.zengqingfa.springboot.validation.demo.entity.UserSaveDto;
import com.zengqingfa.springboot.validation.demo.entity.ValidationList;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/user4")
@Slf4j
public class UserRest4 {

    @PostMapping("/create")
    public String saveUser2(@RequestBody @Validated ValidationList<CreateUserDto> user) {
        log.info("user:{}", user);
        return "save success2";
    }

    @PostMapping("/create2")
    public String saveUser(@RequestBody @Validated CreateUserDto user) {
        log.info("user:{}", user);
        return "save success2";
    }

    @PostMapping("/create3")
    public String saveUser(@RequestBody @Validated UserSaveDto user) {
        log.info("user:{}", user);
        return "saveUser success2";
    }


}
